;;;; Copyright 2009 Peter von Etter

;;;; This file is part of Autoproject

;;;; Autoproject is free software: you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation, either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;; Autoproject is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with Autoproject.  If not, see
;;;; <http://www.gnu.org/licenses/>.

(defpackage :autoproject.crud
  (:use :cl) 
  (:import-from :autoproject.util
                #:>> 
                #:FORMAT-LIST
                #:KEYWORDIFY
                #:LISTIFY-HASH
                #:MERGE-PLIST
                #:SPLIT-LIST
                #:ZIP
                #:UNZIP
                #:IT)

  (:export ;; CRUD creation
           #:write-crud-forms 
           #:write-crud-forms-to-file
           #:crud
           #:make-crud
           
           ;; CRUD ops
           #:with-crud
           #:crud-create
           #:crud-create-from-instance
           #:crud-read
           #:crud-read-from-instance
           #:crud-update
           #:crud-update-from-instance
           #:crud-delete
           #:crud-delete-from-instance
           #:crud-match
           #:crud-select
           #:crud-select-raw
                      
           ;; For anonymous access to slots and classes using keywords
           #:get-crud-symbol
           
           #:sql-or
           #:sql-and
           #:sql-op
           #:sql-quote
           
           #:merge-select
           #:make-select
           #:apply-select
           #:select-count
           #:get-select-property
           #:set-select-property
           #:select-next-page
           #:select-previous-page

           #:select-mapc
           #:select-mapcar
           #:select-remove-if
           #:select-buffered

           #:define-foreign-key
           #:resolve-key
           #:assign-key)
  
 
  (:documentation "

Provides code to automatically generate an ORM.

Operations supported:

- create
- read
- update
- delete
- match

All tables should have a primary integer key.

"))


(defpackage :autoproject.crud.temp 
  (:use :cl)
  (:documentation "A temporary package used when generating cruds."))

;; For delete-system
(autoproject.util::register-system
 :autoproject.crud
 '(:autoproject.crud :autoproject.crud.temp))
